package com.ruoyi.web.controller.biz;

import com.ruoyi.biz.domain.BizFeedback;
import com.ruoyi.biz.domain.vo.BizFeedbackVO;
import com.ruoyi.biz.service.IBizFeedbackService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 意见反馈Controller
 * 
 * @author ruoyi
 * @date 2021-12-17
 */
@RestController
@RequestMapping("/biz/feedback")
public class BizFeedbackController extends BaseController
{
    @Autowired
    private IBizFeedbackService bizFeedbackService;

    /**
     * 查询意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizFeedback bizFeedback)
    {
        startPage();
        List<BizFeedback> list = bizFeedbackService.selectBizFeedbackList(bizFeedback);
        return getDataTable(list);
    }

    /**
     * 查询意见反馈列表
     */
    @GetMapping("/select")
    public TableDataInfo select(String startTime, String endTime)
    {
        startPage();
        List<BizFeedbackVO> list = bizFeedbackService.selectFeedbackRecordList(startTime, endTime);
        return getDataTable(list);
    }


    /**
     * 获取意见反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizFeedbackService.selectBizFeedbackById(id));
    }

    /**
     * 新增意见反馈
     */
    @Log(title = "新增意见反馈", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(BizFeedback bizFeedback)
    {
        return toAjax(bizFeedbackService.insertBizFeedback(bizFeedback));
    }

    /**
     * 新增意见反馈
     */
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(BizFeedback bizFeedback)
    {
        return toAjax(bizFeedbackService.updateBizFeedback(bizFeedback));
    }


    /**
     * 删除意见反馈
     */
    @PreAuthorize("@ss.hasPermi('system:feedback:remove')")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizFeedbackService.deleteBizFeedbackByIds(ids));
    }
}
